package com.ruoyi.businessSku.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.businessSku.domain.BusinessSku;
import com.ruoyi.businessSku.service.IBusinessSkuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务商品管理Controller
 * 
 * @author ruoyi
 * @date 2025-07-20
 */
@RestController
@RequestMapping("/ruoyi/businessSku")
public class BusinessSkuController extends BaseController
{
    @Autowired
    private IBusinessSkuService businessSkuService;

    /**
     * 查询业务商品管理列表
     */
    // @PreAuthorize("@ss.hasPermi('ruoyi:businessSku:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessSku businessSku)
    {
        startPage();
        List<BusinessSku> list = businessSkuService.selectBusinessSkuList(businessSku);
        return getDataTable(list);
    }

    /**
     * 导出业务商品管理列表
     */
//    @PreAuthorize("@ss.hasPermi('ruoyi:businessSku:export')")
    @Log(title = "业务商品管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusinessSku businessSku)
    {
        List<BusinessSku> list = businessSkuService.selectBusinessSkuList(businessSku);
        ExcelUtil<BusinessSku> util = new ExcelUtil<BusinessSku>(BusinessSku.class);
        util.exportExcel(response, list, "业务商品管理数据");
    }

    /**
     * 获取业务商品管理详细信息
     */
    // @PreAuthorize("@ss.hasPermi('ruoyi:businessSku:query')")
    @GetMapping(value = "/{skuId}")
    public AjaxResult getInfo(@PathVariable("skuId") Long skuId)
    {
        return success(businessSkuService.selectBusinessSkuBySkuId(skuId));
    }

    /**
     * 新增业务商品管理
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:businessSku:add')")
    @Log(title = "业务商品管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessSku businessSku)
    {
        return toAjax(businessSkuService.insertBusinessSku(businessSku));
    }

    /**
     * 修改业务商品管理
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:businessSku:edit')")
    @Log(title = "业务商品管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessSku businessSku)
    {
        return toAjax(businessSkuService.updateBusinessSku(businessSku));
    }

    /**
     * 删除业务商品管理
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:businessSku:remove')")
    @Log(title = "业务商品管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{skuIds}")
    public AjaxResult remove(@PathVariable Long[] skuIds)
    {
        return toAjax(businessSkuService.deleteBusinessSkuBySkuIds(skuIds));
    }
}
